import 'package:daoyi_ui_admin_getx/app/common/styles/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';

import 'common_image_widget.dart';

const List<String> defaultImages = [
  "https://res.gemiman.com/5dd97b92d34476d0f2ffd533034d548239cebbdd51f70332c67d2f2418e422c1.png",
  "https://res.gemiman.com/be0e4de65ec23033ae916ae43d799814a3c7ab9386d69417a7adcec960a07eb5.png",
  "https://res.gemiman.com/a9590817692e8dcfd8e3e2f50f4f173bbc2ab2543d8ece1979d9841d2b6da70c.png",
  "https://res.gemiman.com/8ad34acd7effca4a3d3f05d8049a876b4359455d3348384980b131dbd3ec9822.png"
];

const imageWidth = 750.0;
const imageHeight = 424.0;

class CommonSwiperWidget extends StatelessWidget {
  final List<String> images;

  const CommonSwiperWidget({super.key, this.images = defaultImages});

  @override
  Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    var height = size.width / imageWidth * imageHeight;
    return SizedBox(
      height: height,
      child: Swiper(
        itemBuilder: (context, index) {
          return CommonImageWidget(
            images[index],
            fit: BoxFit.fill,
          );
        },
        itemCount: images.length,
        pagination: const SwiperPagination(
          builder: DotSwiperPaginationBuilder(
            color: AppTheme.secondaryColor,
            activeColor: AppTheme.themeColor,
          ),
        ),
        // control: const SwiperControl(),
        autoplay: true,
        autoplayDelay: 5000,
      ),
    );
  }
}
